package InputPreparer;

import java.util.ArrayList;

import Definitions.NodeClass;
import Global.ConstantVariable;
import Global.GlobalClass;
import Sampling.SamplingAbstractClass;

public class ContentPreparerWithSelectedFeatures extends ContentPreparerClass
{
	int[] selectedFeatures;

	public int[] getSelectedFeatures() 
	{
		return selectedFeatures;
	}

	public void setSelectedFeatures(int[] selectedFeatures) 
	{
		this.selectedFeatures = selectedFeatures;
	}

	public ContentPreparerWithSelectedFeatures(SamplingAbstractClass currentSampling, GlobalClass global,int contentType, int[] selectedFearures) 
	{
		super(currentSampling, global);
		this.name =ConstantVariable.InputPreparer_Constants.CONTENT_INPUT_WITH_SELECTED_FEATURES;
		this.contentType =contentType;
		this.selectedFeatures = selectedFearures;
		// TODO Auto-generated constructor stub
	}
	
	public ContentPreparerWithSelectedFeatures(int[] selectedFeature, SamplingAbstractClass currentSampling, GlobalClass global) 
	{
		super(currentSampling, global);
		this.selectedFeatures =new int [selectedFeature.length];
		
		for(int i=0 ; i<selectedFeature.length;i++)
		{
			selectedFeatures[i] = selectedFeature[i];
		}
	}
	
	
	public ArrayList <Double> getInput(NodeClass u, int stage)
	{	
		ArrayList<Double> input =new ArrayList<Double>();
		ArrayList<Double> attributes = u.getContentList().get(this.contentType).getAttributeList();
		
		for(int i=0;  i<selectedFeatures.length ;i ++) 
		{
			input.add(attributes.get(selectedFeatures[i]));
		}
		return input;
	}
	
	public static void Test(NodeClass u, SamplingAbstractClass currentSampling, GlobalClass global)
	{
		int[] selectedFeatures=new int[5];
		
		ContentPreparerClass prep = new ContentPreparerWithSelectedFeatures(selectedFeatures, currentSampling, global);
		
		ArrayList<Double> list = prep.getInput(u, ConstantVariable.Sampling_Constants.NODE_IS_IN_TEST_SET_FOR_THE_FOLD);
		
		for(int i=0 ; i<list.size() ;i++)
		{
			if(list.get(i)!= (double)u.getContentList().get(0).getAttributeList().get(selectedFeatures[i]))
			{
				System.out.println("False ");
			}
		}
		
		System.out.println("Content Input With Selected  Features Test Result :");
		for(Double f : list )
		{
			System.out.print(f+"  ");
		}
			
		System.out.println();
	}

	
	
}

